package org.pidan.basic.designModel.singleton;

/**
 * {@code @description}: 静态内部类
 * 结合了懒汉式和饿汉式各自的优点，真正需要对象的时候才会加载，加载类是线程安全的。
 * {@code @author}: huangyuxin
 * {@code @date}: 2023-11-15
 */
public class JingTaiNeiBuLei {

    private JingTaiNeiBuLei() {

        System.out.println("私有静态内部类初始化");
    }

    public static class SingletonClassInstance {
        private static final JingTaiNeiBuLei jingtaineibulei = new JingTaiNeiBuLei();
    }

    /**
     * 方法没有同步
     */
    public static JingTaiNeiBuLei getInstance() {
        return SingletonClassInstance.jingtaineibulei;
    }

    public static void main(String[] args) {

//        JingTaiNeiBuLei jingTaiNeiBuLei1 = JingTaiNeiBuLei.getInstance();
//        JingTaiNeiBuLei jingTaiNeiBuLei2 = JingTaiNeiBuLei.getInstance();
//
//        System.out.println(jingTaiNeiBuLei1 == jingTaiNeiBuLei2);
        System.out.println(111);
    }
}
